<script>
	import routeInterceptor from '@/util/router/index.ts';

	export default {
		onLaunch: async function (e) {
			// var pages = getCurrentPages();
			// var page = pages[pages.length - 1];
			// console.log(pages);
			let token = uni.getStorageSync('access-network').token;
			// if (!token && uni.getStorageSync('role_play') == 'u-network') {
			// 	uni.reLaunch({
			// 		url: "/pages/pages_network/login/login"
			// 	})
			// }
			if (token && uni.getStorageSync('role_play') == 'u-network') {
				uni.reLaunch({
					url: '/pages_network/home/home',
				});
			}
			let tokenUser = uni.getStorageSync('access-user').token;
			// if (!tokenUser && uni.getStorageSync('role_play') == 'u-user') {
			// 	uni.reLaunch({
			// 		url: "/pages/pages_user/login/login"
			// 	})
			// }
			if (tokenUser && uni.getStorageSync('role_play') == 'u-user') {
				uni.reLaunch({
					url: '/pages_user/home/home',
				});
			}
			if (uni.getStorageSync('role_play') == 'u-user') {
				if (e.query.custCode) {
					uni.setStorageSync('custCode', e.query.custCode);
				}
				if (e.query.moduleCode) {
					store.commit('setWayType', {
						id: e.query.moduleCode,
						name: '报单',
						type: e.query.type,
					});
				}
			}
			// 对路由进行统一拦截，实现路由导航守卫 router.beforeEach 功能
			routeInterceptor(); // 调用路由拦截函数
		},
		onShow: async function () {},
		onHide: function () {
			uni.hideLoading();
		},
		onLoad: function (e) {
			uni.hideLoading();
		},
	};
</script>

<style lang="scss">
	@import './styles/common.scss';

	/*每个页面公共css */
	:deep(.uni-modal__title) {
		font-size: 32rpx !important;
	}

	:deep(.uni-modal__bd) {
		color: #000 !important;
	}

	#app {
		background-color: #fafafa;
		font-size: 32rpx;
		-webkit-user-select: text;
		-moz-user-select: text;
		-ms-user-select: text;
		user-select: text;

		:deep(.uni-page-head .uni-page-head__title) {
			font-size: 32rpx !important;
			font-weight: normal;
		}

		:deep(.uni-tabbar__label) {
			margin-top: 0 !important;
		}
	}
</style>
